<html>
<head><meta charset="utf-8"><title>core::ffi::CStr ? · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html">core::ffi::CStr ?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="146877369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146877369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146877369">(Nov 06 2018 at 16:49)</a>:</h4>
<p>why is <code>std::ffi::CStr</code> not in <code>core</code> ?</p>



<a name="146877456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146877456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146877456">(Nov 06 2018 at 16:50)</a>:</h4>
<p>or in libc ?</p>



<a name="146877479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146877479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146877479">(Nov 06 2018 at 16:50)</a>:</h4>
<p>it might not make sense for <code>core</code> because it would require <code>libc</code> for <code>c_char</code>, but it could be exposed in <code>libc</code> so that one does not need <code>libstd</code> to use it</p>



<a name="146877813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146877813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146877813">(Nov 06 2018 at 16:56)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> because right now, CStr is not really ffi safe</p>



<a name="146877833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146877833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146877833">(Nov 06 2018 at 16:56)</a>:</h4>
<p>if it were a thin pointer, maybe</p>



<a name="146877838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146877838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146877838">(Nov 06 2018 at 16:56)</a>:</h4>
<p>although maybe there's an argument for core</p>



<a name="146877861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146877861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146877861">(Nov 06 2018 at 16:57)</a>:</h4>
<p>we could put it in <code>core</code> if we require <code>char</code> to be 1 byte in the UCG</p>



<a name="146877877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146877877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146877877">(Nov 06 2018 at 16:57)</a>:</h4>
<p>but otherwise, <code>core</code> does not know <code>c_char</code></p>



<a name="146877947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146877947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146877947">(Nov 06 2018 at 16:58)</a>:</h4>
<p><span class="user-mention" data-user-id="125253">@Nicole Mazzuca</span> why isn't CStr just a *[const,mut] c_char ?</p>



<a name="146877969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146877969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146877969">(Nov 06 2018 at 16:59)</a>:</h4>
<p>is there a way to make a type be "unsized" ?</p>



<a name="146877998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146877998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146877998">(Nov 06 2018 at 16:59)</a>:</h4>
<p>e.g. <code>struct CStr(*mut c_char);  impl !Sized for CStr {}</code></p>



<a name="146878020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878020">(Nov 06 2018 at 17:00)</a>:</h4>
<p>nope</p>



<a name="146878057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878057">(Nov 06 2018 at 17:00)</a>:</h4>
<p>not as of yet</p>



<a name="146878081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878081">(Nov 06 2018 at 17:00)</a>:</h4>
<p>it's a <code>struct CStr([c_char]);</code> right now</p>



<a name="146878096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878096">(Nov 06 2018 at 17:00)</a>:</h4>
<p>which means it's unsized, but not thin</p>



<a name="146878135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878135">(Nov 06 2018 at 17:01)</a>:</h4>
<p>is there an unsized type that's one pointer wide ?</p>



<a name="146878213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878213">(Nov 06 2018 at 17:02)</a>:</h4>
<p>no</p>



<a name="146878215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878215">(Nov 06 2018 at 17:02)</a>:</h4>
<p>not right now</p>



<a name="146878221"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878221" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878221">(Nov 06 2018 at 17:02)</a>:</h4>
<p>we need custom DSTs</p>



<a name="146878347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878347">(Nov 06 2018 at 17:04)</a>:</h4>
<p>lol, even trait objects of traits without methods are 16 bytes wide</p>



<a name="146878378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878378">(Nov 06 2018 at 17:05)</a>:</h4>
<p>why ?</p>



<a name="146878390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878390">(Nov 06 2018 at 17:05)</a>:</h4>
<p>because nobody has put in the work to do this yet</p>



<a name="146878433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878433">(Nov 06 2018 at 17:06)</a>:</h4>
<p>and for that, because you still need size, align, and drop</p>



<a name="146878477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878477">(Nov 06 2018 at 17:06)</a>:</h4>
<p><code>trait Bar {} struct CStr(dyn Bar);</code> could work iff <code>dyn Bar</code> would be pointer sized because there is no need for a <code>vtable</code> pointer</p>



<a name="146878481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878481">(Nov 06 2018 at 17:07)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> also even if the trait has no method you need a vtable for size, alignment and <code>drop</code></p>



<a name="146878497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878497">(Nov 06 2018 at 17:07)</a>:</h4>
<p>oh</p>



<a name="146878514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878514">(Nov 06 2018 at 17:07)</a>:</h4>
<p>there is <span class="user-mention" data-user-id="119009">@eddyb</span>'s trick with <code>extern type</code></p>



<a name="146878523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878523">(Nov 06 2018 at 17:07)</a>:</h4>
<p>but then you lose size_of_val</p>



<a name="146878524"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878524" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878524">(Nov 06 2018 at 17:07)</a>:</h4>
<p>because it turns out that with <code>extern { type Foo; }</code>, <code>Foo</code> <em>is</em> DST and thin</p>



<a name="146878569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878569">(Nov 06 2018 at 17:08)</a>:</h4>
<p>which is a breaking change</p>



<a name="146878576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878576">(Nov 06 2018 at 17:08)</a>:</h4>
<p>but yeah there are lots of unanswered questions around that</p>



<a name="146878600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878600">(Nov 06 2018 at 17:08)</a>:</h4>
<p><span class="user-mention" data-user-id="125253">@Nicole Mazzuca</span>  I suppose <code>CStr</code> wants to be a custom DST where <code>size_of_val</code> does <code>strlen</code>?</p>



<a name="146878611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878611">(Nov 06 2018 at 17:08)</a>:</h4>
<p>yes</p>



<a name="146878614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878614">(Nov 06 2018 at 17:08)</a>:</h4>
<p>yes</p>



<a name="146878642"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878642" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878642">(Nov 06 2018 at 17:09)</a>:</h4>
<p>I mean, its in <code>std::ffi::CStr</code>, and its not FFI safe</p>



<a name="146878652"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878652" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878652">(Nov 06 2018 at 17:09)</a>:</h4>
<p>yeah</p>



<a name="146878654"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878654" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878654">(Nov 06 2018 at 17:09)</a>:</h4>
<p>it's quite ridiculous</p>



<a name="146878714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878714">(Nov 06 2018 at 17:10)</a>:</h4>
<p>we don't need full DST for this, some rustc_ magic to allow implementing it would suffice</p>



<a name="146878751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878751">(Nov 06 2018 at 17:10)</a>:</h4>
<p>that seems... unfortunate</p>



<a name="146878795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878795">(Nov 06 2018 at 17:11)</a>:</h4>
<p>i mean, full DSTs would be cool but i wouldn't block fixing CStr on it</p>



<a name="146878806"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878806" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878806">(Nov 06 2018 at 17:11)</a>:</h4>
<p>it also seems like a lot of work for that</p>



<a name="146878809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878809">(Nov 06 2018 at 17:12)</a>:</h4>
<p>*just that</p>



<a name="146878857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878857">(Nov 06 2018 at 17:12)</a>:</h4>
<p>frankly, we should just fix DSTs now</p>



<a name="146878867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878867">(Nov 06 2018 at 17:12)</a>:</h4>
<p>as opposed to inventing a solution for exactly one type</p>



<a name="146878874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878874">(Nov 06 2018 at 17:12)</a>:</h4>
<p>re-open the RFC ?</p>



<a name="146878881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878881">(Nov 06 2018 at 17:12)</a>:</h4>
<p>yeah</p>



<a name="146878882"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878882" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878882">(Nov 06 2018 at 17:12)</a>:</h4>
<p>alright</p>



<a name="146878888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878888">(Nov 06 2018 at 17:12)</a>:</h4>
<p>ping me in 10 hours?</p>



<a name="146878896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878896">(Nov 06 2018 at 17:13)</a>:</h4>
<p>I'll put in the work to get it up to snuff</p>



<a name="146878914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878914">(Nov 06 2018 at 17:13)</a>:</h4>
<p>i'll be sleeping in 10 hours probably</p>



<a name="146878917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878917">(Nov 06 2018 at 17:13)</a>:</h4>
<p>fair</p>



<a name="146878927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878927">(Nov 06 2018 at 17:13)</a>:</h4>
<p>will be 2 am over here :D</p>



<a name="146878928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878928">(Nov 06 2018 at 17:13)</a>:</h4>
<p>well, no promises, but if I remember lol</p>



<a name="146878932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878932">(Nov 06 2018 at 17:13)</a>:</h4>
<p>where are you?</p>



<a name="146878937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878937">(Nov 06 2018 at 17:13)</a>:</h4>
<p>germany</p>



<a name="146878945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146878945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146878945">(Nov 06 2018 at 17:13)</a>:</h4>
<p>ah, cool</p>



<a name="146879003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146879003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146879003">(Nov 06 2018 at 17:14)</a>:</h4>
<p>:D</p>



<a name="146880448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146880448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146880448">(Nov 06 2018 at 17:39)</a>:</h4>
<p>Frankly we could add an unstable <code>DynSized</code> trait that overloads the <code>size_of_val</code> that you'd get for a DST</p>



<a name="146880469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146880469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146880469">(Nov 06 2018 at 17:39)</a>:</h4>
<p>that would solve the problem for CStr at least, and we can punt figuring out custom DST until later</p>



<a name="146880527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146880527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146880527">(Nov 06 2018 at 17:40)</a>:</h4>
<p>I'm not sure it would even be that hard, you just treat the compiler-provided one as a <code>default fn</code> method</p>



<a name="146880544"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146880544" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146880544">(Nov 06 2018 at 17:40)</a>:</h4>
<p>but I'd also clue in <span class="user-mention" data-user-id="116009">@nikomatsakis</span> first</p>



<a name="146881006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146881006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146881006">(Nov 06 2018 at 17:47)</a>:</h4>
<p>from a miri perspective I am actively scared of <code>size_and_align_of_mplace</code> executing arbitrary code</p>



<a name="146881123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146881123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kennytm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146881123">(Nov 06 2018 at 17:48)</a>:</h4>
<p>what if we require the overridden <code>size_of_val</code>/<code>align_of_val</code> to be <code>const</code></p>



<a name="146881144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146881144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kennytm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146881144">(Nov 06 2018 at 17:49)</a>:</h4>
<p>(assuming <code>strlen</code> can be <code>const</code>)</p>



<a name="146881235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146881235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146881235">(Nov 06 2018 at 17:50)</a>:</h4>
<p>uh that is an interesting idea</p>



<a name="146881243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146881243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146881243">(Nov 06 2018 at 17:50)</a>:</h4>
<p>doesnt make me less scared TBH but still interesting^^</p>



<a name="146881246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146881246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146881246">(Nov 06 2018 at 17:50)</a>:</h4>
<p><code>strlen</code> can be a <code>const fn</code>, but we will want to call C's <code>strlen</code> when it is not executed at compile-time</p>



<a name="146881284"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146881284" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146881284">(Nov 06 2018 at 17:50)</a>:</h4>
<p>I think we should be calling our own TBH</p>



<a name="146881327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146881327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146881327">(Nov 06 2018 at 17:51)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> that might be a big performance regression at run-time</p>



<a name="146881362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146881362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kennytm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146881362">(Nov 06 2018 at 17:52)</a>:</h4>
<p>i suppose the runtime <code>strlen</code> would involve SIMD and maybe read slightly beyond the allocated region</p>



<a name="146881406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146881406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146881406">(Nov 06 2018 at 17:52)</a>:</h4>
<p>the one in the C library might do run-time feature detection for large strings, use SSE, AVX, ... intrinsics, inline assembly, or even be fully written in assembly</p>



<a name="146881446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146881446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146881446">(Nov 06 2018 at 17:52)</a>:</h4>
<p>i forgot the trick of reading out of bounds</p>



<a name="146881486"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146881486" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kennytm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146881486">(Nov 06 2018 at 17:53)</a>:</h4>
<p>we could always turn <code>strlen</code> into an intrinsic <span class="emoji emoji-1f643" title="upside down">:upside_down:</span></p>



<a name="146881575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146881575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146881575">(Nov 06 2018 at 17:54)</a>:</h4>
<p>yeah, the goalt here isn't evolving custom DST or const fn, but fixing CStr</p>



<a name="146881873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146881873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kennytm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146881873">(Nov 06 2018 at 17:58)</a>:</h4>
<p>do we need a thin CStr <em>today</em>? <code>core::ffi::CStr</code> only needs a <code>core::ffi::c_char</code>. if you need to pass the CStr into FFI functions you could still use <code>.as_ptr()</code></p>



<a name="146882317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146882317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146882317">(Nov 06 2018 at 18:05)</a>:</h4>
<p>no, but it's confusing and frustrating to do that</p>



<a name="146882600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146882600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146882600">(Nov 06 2018 at 18:10)</a>:</h4>
<p>it would make working with C FFI so much better, working with <code>*mut c_char</code> sucks and is very error prone (forgot to check the <code>\0</code> terminator ? etc. )</p>



<a name="146883338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146883338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146883338">(Nov 06 2018 at 18:22)</a>:</h4>
<p>C strings and element-pointer+length arrays are the only thing in Rust's FFI to LLVM that are not safe types right now</p>



<a name="146883375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146883375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146883375">(Nov 06 2018 at 18:22)</a>:</h4>
<p>since @irinagpopa made all of the LLVM classes be used by reference (relying on <code>extern type</code> ofc)</p>



<a name="146886270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146886270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146886270">(Nov 06 2018 at 19:09)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> <a href="https://internals.rust-lang.org/t/pre-rfc-custom-dsts/8777" target="_blank" title="https://internals.rust-lang.org/t/pre-rfc-custom-dsts/8777">https://internals.rust-lang.org/t/pre-rfc-custom-dsts/8777</a></p>



<a name="146893651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146893651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146893651">(Nov 06 2018 at 20:54)</a>:</h4>
<p>re miri: even with const fn this requires machine steps to execute for determining the size. that's just scary^^</p>



<a name="146893674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146893674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146893674">(Nov 06 2018 at 20:55)</a>:</h4>
<p><span class="user-mention" data-user-id="125254">@kennytm</span> uh I dont think reading beyond the allocated region is something LLVM allows you to do^^</p>



<a name="146928245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/core%3A%3Affi%3A%3ACStr%20%3F/near/146928245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/core.3A.3Affi.3A.3ACStr.20.3F.html#146928245">(Nov 07 2018 at 09:17)</a>:</h4>
<p><span class="user-mention" data-user-id="125253">@Nicole Mazzuca</span> thanks!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>